const path = require('path');
const webpack = require('webpack');
const CopyWebpackPlugin = require('copy-webpack-plugin')
module.exports = {
  entry: {
    app: './src/pages/quoted/index.js'
  },

  output: {
    filename: '[name].bundle.js',
    path: path.resolve(__dirname, 'dist', 'quoted')
  },

  module: {
    rules: [
      {
        test: /\.css$/,
        exclude: /node_modules/,
        use: [{
          loader: 'style-loader'
        },{
          loader: 'css-loader',
          options: {
            importLoaders: 1
          }
        },{
          loader: 'postcss-loader'
        }]
      },

      {
        test: /\.scss$/,
        exclude: /node_modules/,
        use: [{
          loader: 'style-loader'
        },{
          loader: 'css-loader',
          options: {
              importLoaders: 1
            }
          },{
            loader: 'postcss-loader'
          },{
            loader: 'sass-loader'
        }]
        
        
        
        
        
        
      },

      {
        test: /\.(jpg|png|svg|gif)$/,
        exclude: /node_modules/,
        use: [{
          loader: 'url-loader',
          options: {
            limit: 10000,
            name: 'images/[name].[ext]'
          }
        }]

      },

      {
        test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/,
        exclude: /node_modules/,
        use: [{
          loader: 'url-loader',
          options: {
            limit: 10000,
            name: 'media/[name].[ext]'
          }
        }]

      },

      {
        test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
        exclude: /node_modules/,
        use: [{
          loader: 'url-loader',
          options: {
            limit: 10000,
            name: 'fonts/[name].[ext]'
          }
        }]

      },

      {
        test: /\.m?js$/,
        exclude: /(node_modules|bower_components)/,
        use: {
          loader: 'babel-loader',
          options: {
            presets: ['@babel/preset-env'],
            plugins: ['@babel/plugin-transform-runtime'] 
          }
        }
      },

      {
        test: /\.hbs$/,
        loader: "handlebars-loader"
        
      }
      
    ]
  },
  plugins: [
    new webpack.ProvidePlugin({ // 这里定义了jquery可以直接在整个项目中使用$或者jQuery，不需要定义
      $: 'jquery',
      jQuery: 'jquery'
    }),
    new CopyWebpackPlugin([
      {
        from: path.resolve(__dirname, './src/pages/quoted/images'),
        to: path.resolve(__dirname, './dist/quoted/images'),
        ignore: ['.*']
      }
    ])
  ]


};